home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!gate.demon.co.uk
- From: Jason <tmr@cosine.demon.co.uk>
- Newsgroups: comp.sys.cbm
- Subject: Re: Commodore Arithmetic (Energy Bars)
- Date: Wed, 21 Feb 96 02:14:56 GMT
- Organization: Cosine Systems
- Message-ID: <9602210214.AA000i3@cosine.demon.co.uk>
- References: <100751374@news.acns.nwu.edu> <823986319@p71.f411.n201.z2.ftn> <4g2ld5$i47@barad-dur.nas.com> <4gaoja$8di@gatekeeper2.svl.trw.com>
- X-NNTP-Posting-Host: gate.demon.co.uk
- X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
- X-Mail2News-Path: relay-1.mail.demon.net!gate.demon.co.uk
-
- Mike Domingo (Mike_Domingo@smtp.svl.trw.com) wrote:
- : I've been knocking my brains over creating a simple Energy Bar. My bar
- : is used to display disk drive "blocks free". My "Assembly Programming
- : for the Commodore 64" has examples of simple arithmetic but nothing
- : else. Could someone post an example of an Engergy Bar display routine?
- : I'm most interesting in the arithmetic routines for calculating a
- : percentage of a whole (multiple byte division?) for larger numbers.
- :
- : ex. display blocks = (max display blocks / (current blocks free/max
- : blocks free))
-
- Right, source code time eh? This assumes that char 0 is a clear, char 1 has
- a 1 pixel line down the left side, char 2 a 2 pixel line and so on till char
- 8 which is a solid block... The label NRG is the present setting.
-
- LDX #$00 This bit just clears the line for the bar.
- LDA #$20
- CLRBAR STA $0400,X
- INX
- CPX #$20
- BNE CLRBAR
-
- LDA NRG This bit works out how many solid char blocks the
- LSR bar is going to take and plots them.
- LSR
- LSR
- TAY
- LDX #$00
- LDA #$08
- MAINBAR STA $0400,X
- INX
- DEY
- BPL MAINBAR
-
- LDA NRG Finally, this bit works out the remaining pixels
- AND #$07 and adds them to the end of the bar.
- CLC
- ADC #$01
- DEX
- STA $0400,X
- RTS
-
- There, thats a bit slapdash, but it does work and it's flexible enough to
- allow you to change the value in NRG very rapidly. BTW, a value of 0 will
- produce a single 1 pixel thin bar.
-
- Please note: this routine is merely for displaying a bar, nothing else.
- Simply feed it a value and start it up.
-
- Jason =-)
-